package com.tianqu.tms.entity;

import java.sql.Timestamp;

import com.tianqu.tms.core.base.TmsEntity;
import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.dao.MarketPadPicDao;
import com.tianqu.tms.dao.TmsDao;
import com.tianqu.tms.dto.MarketPadPicDto;

public class MarketPadPic extends TmsEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private long id;
	//车牌号码
	private String licensePlate;
	//表显里程
	private int mileage;
	//预售价格
	private int price;
	//左前车图
	private String carImage1;
	//右前车图
	private String carImage2;
	//左后车图
	private String carImage3;
	//右后车图
	private String carImage4;
	//受理状态  1：未受理 2：以受理 3.不处理
	private int status;
	//受理日期
	private Timestamp insertTime;
	//受理人
	private int insertUserId;
	//更新时间
	private Timestamp updateTime;
	//更新用户
	private int updateUserId;
	
	@Override
	public void save() throws TmsDaoException, TmsException {
		// TODO Auto-generated method stub
		
	}
	
	public static MarketPadPic getInstance(){
		MarketPadPic marketPadPic = new MarketPadPic();
		marketPadPic.setExisting(false);
		return marketPadPic;
	}

	/**
	 * 根据车牌号码查询
	 * @param licensePlate
	 * @return
	 * @throws TmsDaoException
	 */
	public MarketPadPic findDtoByLicensePlate(String licensePlate)throws TmsDaoException{
		MarketPadPic marketPadPic = MarketPadPic.getInstance();
		MarketPadPicDto dto = new MarketPadPicDto();
		MarketPadPicDao marketPadPicDao = (MarketPadPicDao) TmsDao.getInstance(TmsDao.TMS_MARKET_PAD_PIC);
		dto = marketPadPicDao.findByLicensePlate(licensePlate);
		marketPadPic.dtoToEntity(dto);
		return marketPadPic;
	}
	
	/**
	 * 更新操作
	 * @param marketPadPic
	 * @throws TmsDaoException
	 */
	public void updateMarketPadPic(MarketPadPic marketPadPic)throws TmsDaoException{
		MarketPadPicDto dto = new MarketPadPicDto();
		MarketPadPicDao marketPadPicDao = (MarketPadPicDao) TmsDao.getInstance(TmsDao.TMS_MARKET_PAD_PIC);
		dto = entityToDto(marketPadPic);
		marketPadPicDao.updateMarketPadPic(dto);
	}
	
	/**
	 * 插入操作
	 * @param marketPadPic
	 * @throws TmsDaoException
	 */
	public void insertMarketPadPic(MarketPadPic marketPadPic)throws TmsDaoException{
		MarketPadPicDto dto = new MarketPadPicDto();
		MarketPadPicDao marketPadPicDao = (MarketPadPicDao) TmsDao.getInstance(TmsDao.TMS_MARKET_PAD_PIC);
		dto = entityToDto(marketPadPic);
		marketPadPicDao.insertMarketPadPid(dto);
	}
	
	/**
	 * dto -> entity
	 * @return
	 */
	private void dtoToEntity(MarketPadPicDto dto){
		
		this.setMileage(dto.getMileage());
		this.setId(dto.getId());
		this.setLicensePlate(dto.getLicensePlate());
		this.setPrice(dto.getPrice());
		this.setCarImage1(dto.getCarImage1());
		this.setCarImage2(dto.getCarImage2());
		this.setCarImage3(dto.getCarImage3());
		this.setCarImage4(dto.getCarImage4());
		this.setInsertTime(dto.getInsertTime());
		this.setInsertUserId(dto.getInsertUserId());
		this.setUpdateTime(dto.getUpdateTime());
		this.setUpdateUserId(dto.getUpdateUserId());
		
	}
	
	
	/**
	 * entity -> dto
	 * @param entity
	 * @return
	 */
	private MarketPadPicDto entityToDto(MarketPadPic entity){
		MarketPadPicDto dto = new MarketPadPicDto();
		dto.setId(entity.getId());
		dto.setLicensePlate(entity.getLicensePlate());
		dto.setMileage(entity.getMileage());
		dto.setPrice(entity.getPrice());
		dto.setCarImage1(entity.getCarImage1());
		dto.setCarImage2(entity.getCarImage2());
		dto.setCarImage3(entity.getCarImage3());
		dto.setCarImage4(entity.getCarImage4());
		dto.setInsertTime(entity.getInsertTime());
		dto.setInsertUserId(entity.getInsertUserId());
		dto.setUpdateTime(entity.getUpdateTime());
		dto.setUpdateUserId(entity.getUpdateUserId());
		dto.setStatus(entity.getStatus());
		return dto;
	}
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getLicensePlate() {
		return licensePlate;
	}

	public void setLicensePlate(String licensePlate) {
		this.licensePlate = licensePlate;
	}

	public int getMileage() {
		return mileage;
	}

	public void setMileage(int mileage) {
		this.mileage = mileage;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public String getCarImage1() {
		return carImage1;
	}

	public void setCarImage1(String carImage1) {
		this.carImage1 = carImage1;
	}

	public String getCarImage2() {
		return carImage2;
	}

	public void setCarImage2(String carImage2) {
		this.carImage2 = carImage2;
	}

	public String getCarImage3() {
		return carImage3;
	}

	public void setCarImage3(String carImage3) {
		this.carImage3 = carImage3;
	}

	public String getCarImage4() {
		return carImage4;
	}

	public void setCarImage4(String carImage4) {
		this.carImage4 = carImage4;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Timestamp getInsertTime() {
		return insertTime;
	}

	public void setInsertTime(Timestamp insertTime) {
		this.insertTime = insertTime;
	}

	public int getInsertUserId() {
		return insertUserId;
	}

	public void setInsertUserId(int insertUserId) {
		this.insertUserId = insertUserId;
	}

	public Timestamp getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Timestamp updateTime) {
		this.updateTime = updateTime;
	}

	public int getUpdateUserId() {
		return updateUserId;
	}

	public void setUpdateUserId(int updateUserId) {
		this.updateUserId = updateUserId;
	}
	
	
	
}
